Skip to content

DEV-1459: merge master (#343) into DEV-1459, and write an audio mode set before a read - #352

Merged
JongChern merged 18 commits into
DEV-1459from
DEV-1459_master_merge
Nov 16, 2026
Merged

JongChern merged 18 commits into
DEV-1459from
DEV-1459_master_merge

Conversation

@JongChern

@JongChern JongChern commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

DEV-1459. Brings DEV-1459 up to date with master, which now has #343 (DEV-971: configuration byte 232, the event channel probe, live event records and event files) merged at 1e607084. Three commits on top of 2610c374, DEV-1459's head.

1. Merge master (cbb0a157)

Five files conflicted. Each conflict was two separate additions at the same place, so both sides are kept:

File Both sides kept
ShimmerBluetooth The command and response maps (GET_AUDIO_STATUS beside GET_EVENT_CHANNEL_STATUS), and the in-stream response branches
ShimmerObject The 0xBC-0xBD constants beside 0xB9-0xBB
Configuration AUDIO_MODE beside the BUTTON_MODE, LOG_TRIGGERS and TTL_INPUT labels
ConfigByteLayoutShimmer3 Byte 232's index beside the audio layout
SensorSoundLevel The parse both sets the audio mode and marks byte 233 as read

On connect, the event channel probe still goes out early and GET_AUDIO_STATUS late.

2. An audio mode set before a read is written (35da512d)

  • The rule from master (DEV-971: #343 review fixes - leave byte 233 out before a read, one NACK handler, renumber tests #351). A configuration written before it is read, for example with configure-on-connect, leaves byte 233 out unless the byte was read or the sound level is on. That keeps the Shimmer's own audio mode instead of writing 0 over it.
  • The defect. With this branch's setAudioMode(), an audio mode set before a read was not written. The new test API_00047.anAudioModeSetBeforeAReadIsWritten failed on the merged code.
  • The fix. SensorSoundLevel.isAudioConfigKnown() now takes the device. It also counts an audio mode that differs from the one read: the same test configBytesGenerate() uses to decide to write it. Off set before a read still leaves the Shimmer's own, since Off is also the default.
  • Who is affected. Only writes made before a read: configure-on-connect and fixed configs. Consensys configures from a copy and writes whole chunks, so it is not affected.
  • Renumbered. API_00042_Shimmer3rAudioStatusTest is now API_00048, because master's API_00042_EventRecordFileTest has that number.

3. Merge DEV-1459 again (ebeaa454)

2610c374 was pushed to DEV-1459 after this PR opened. It adds unansweredAudioStatusKeepsTheConnection to API_00042_Shimmer3rAudioStatusTest, which this branch renames to API_00048, so GitHub reported a conflict. Git carried the new test across the rename, and nothing needed resolving by hand.

Tests

Suite Result
API_00047_AudioConfigWriteTest 7/7. The two tests are new; the first failed before the fix
API_00029_Shimmer3rAudioModeConfigByteTest 4/4
API_00048_Shimmer3rAudioStatusTest (was API_00042) 5/5, with 2610c374's new test
API_00038_EventChannelProbeTest, API_00046_ButtonLogModeConfigWriteTest 6/6, 14/14
ShimmerDriver test 219/219
ShimmerDriverPC clean build 171/171
Java 8 MATLAB jar (shadowJar -PmatlabJava8) Builds
ShimmerPCBasicExamples Compiles

The API_ rows ran on ebeaa454. The rest ran on 35da512d; the merge since adds only a test. CI does not run on PRs into this branch. Not run on a unit.

The Advance API and ConsensysApps DEV-1459 branches call none of what changed.

🤖 Generated with Claude Code

marknolan and others added 18 commits November 2, 2026 15:00
Byte 232 holds the button mode, the log triggers and the TTL input enable
on LogAndStream firmware with the event channel. The full configuration
write built its image from zeros, so every configure from Consensys or the
Android config dialog put 0 there and turned the button back to legacy.

- ButtonLogMode: the byte's fields and the firmware's correction rules
  (log-and-stream-common shimmer_button_log_mode.c, via the web SDK's
  buttonLogMode.ts), including press recording and the TTL input taken
  out on SR48-6-0.
- ShimmerObject: the parse keeps the byte as read, 0xFF included, and
  the generator writes it back (corrected where it can be trusted).
  Before packing bytes 217 and 218 it holds userButtonEnable at the
  button mode's nearest equivalent and clears singleTouchStart where no
  press can start logging, as the firmware does. Getters and setters for
  the three fields, and config labels for them.
- The byte is trusted only when the Shimmer ACKed the probe, or the
  value read is one the firmware keeps: firmware without it leaves 0xFF,
  and the dock cannot probe.
- ShimmerVerObject.isSupportedSetFeature(): SET_FEATURE arrived with
  log-and-stream-common, in LogAndStream_Shimmer3R v1.0.52 and
  LogAndStream_Shimmer3 v1.0.20. Older firmware discards 0xB7 and runs
  the two bytes after it as commands (03 is GET_SAMPLING_RATE, which is
  ACKed), so it is never sent there. The layout places byte 232 from
  those releases on; the event channel's builds report the release
  before them, so the version cannot say more.
- ShimmerBluetooth.readEventChannelSupport(): SET_FEATURE with
  FEATURE_EVENT_STREAM and 0, sent on connect. ACK means the event
  channel is there; the NACK is handled without dropping the link, and
  still counts towards the operation's progress.
- writeConfigBytes(): when the byte was never read nor set, as when a
  configuration is written on connect before the read, the chunk at 128
  is sent either side of byte 232, so the Shimmer keeps its own.

Not benched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
LogAndStream_Shimmer3 v1.00.017 is the first release whose
log-and-stream-common pin has SET_FEATURE (df58877, with the two-byte
argument fix e5ea88c). From v1.00.017 to v1.00.019 the module sat at
LogAndStream/log-and-stream-common, and v1.00.017 builds its Bluetooth
handler from there. The earlier check looked only at the path v1.00.020
moved it to.

The gate moves to v1.0.17, the same release isSupportedRn4678ErrorDetection()
already uses. Those releases NACK FEATURE_EVENT_STREAM, so they read as
having no event channel, and their SET_INFOMEM handler is the same one
that takes the split write around byte 232.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
applyButtonLogModeRules() kept singleTouchStart wherever byte 232 left a
press that can start logging. That rule exists only in a firmware build
with IS_SUPPORTED_SINGLE_TOUCH, and no LogAndStream release has it: every
one clears the bit on each configuration it takes, whatever byte 232
holds. So a full write sent a bit the Shimmer drops, and the driver showed
single touch on where it never acts.

- The rules now clear singleTouchStart on firmware that has byte 232
  (LogAndStream from the release that brought SET_FEATURE, the same gate
  the layout uses), and keep userButtonEnable at the button mode's nearest
  equivalent there as before.
- On other firmware they change nothing. A byte 232 setter called for an
  SDLog Shimmer, or LogAndStream before the byte, used to move
  userButtonEnable and clear single touch on firmware that has neither
  rule, and SDLog is the one firmware the driver offers Single Touch
  Start for.
- API_00037: single touch is cleared in every mode, 0xFF included, and
  firmware without the byte keeps bytes 217 and 218. All three tests fail
  on the old rule.

Not benched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in DEV-1408 (the callback consumer thread survives a throwing handler).
No conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hannel

readEventChannelSupport()'s javadoc: no Shimmer3 release has it yet, and the
builds before a release report the release before them, so the driver still
asks rather than going by the version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the conflict #343 predicted with #293 (DEV-982) in
processNotStreamingWaitForAck(): the event channel probe's NACK is taken
first, then any other NACK as a refusal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nnel status

The Java driver now does the host side of the event channel that the web SDK
does (log-and-stream-common docs/SHIMMER3_EVENT_CHANNEL.md and
SHIMMER3_BT_COMMUNICATION_PROTOCOL.md section 7.15):

- EventFile, EventRecord: the SD card's events/ files, a 64-byte header and
  16-byte records, with pairing to the data file by its initial timestamp.
- writeEventStream(boolean): SET_FEATURE / FEATURE_EVENT_STREAM. Each record
  frame, [0x8A][0xBB][0x10][record][CRC-16], reaches EventChannelListener.
  Frames are taken between data packets (any link CRC mode), straight after the
  opt-in's ACK, at the start of the buffer, and when idle, including before a
  command's ACK or reply. They are only parsed after an opt-in, and only once
  their own CRC checks out.
- readEventChannelStatus(): GET_EVENT_CHANNEL_STATUS_COMMAND (0xB9). Not
  streaming only: its reply is not wrapped in 0x8A, so the streaming parser
  could not tell it from a packet.

Tests port the web SDK's tests/events/record.test.ts inputs and results, and
run the IO thread over an in-memory radio for the streaming and idle paths.

Android's Shimmer.java overrides the streaming parser and does not know the
frame, so it must not opt in until ported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… event channel

Tools > Event markers (Shimmer3R), or the EVENT MARKERS button, opens a window
that does with the Java driver what Shimmer Capture web does with the web SDK:

- whether the unit has the event channel, and asking again;
- configuration byte 232 (button mode, what starts logging, TTL input),
  written with the whole configuration and read back;
- opt in / opt out, the live records with sequence gaps flagged, and the
  frame and bad-CRC counters;
- the event channel status (not while streaming);
- an event file from a card: its header, completeness, the data file it
  pairs with, and its records timed from the file open.

Each live edge is also marked on the main plot as a red vertical bar, placed
by the latest data packet's Shimmer clock against the plot's PC-time axis.

CI does not build ShimmerPCBasicExamples; built locally.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DEV-971: Java event markers - event files, live records, status, and a test window
Each was first reproduced by a test that failed on the unchanged code
(API_00044_EventStreamReviewReproTest), then fixed:

1. Idle: event records right behind an in-stream reply were lost. After an
   unsolicited status push ([ACK][0x8A][0x71]), sent on a dock, an undock or a
   press that starts logging, clearSerialBuffer() wiped the records queued
   behind it (0 of 2 arrived). With the event channel on, the bytes after the
   reply are now left for the next pass. A record frame after a stray ACK no
   longer has link-CRC bytes cleared after it either: it carries its own CRC.
2. Streaming: an ACK nobody waited for, before a record frame, re-ran the ACK
   handling of the SET that went last. It is now taken only while an ACK is
   awaited.
3. Streaming with no link CRC: the packet before a 0x8A was taken as a packet
   even when the 0x8A was a data byte after a lost byte, so misframed bytes
   reached the app as a sample. It is now taken only once the frame after it
   passes its own CRC; otherwise the bytes are discarded as before.
4. readEventChannelStatus() could be queued behind a start of streaming not yet
   acknowledged, and its unwrapped reply, [ACK][0xBA][9], was then not taken
   between data packets and the command timed out. It is now refused while a
   start of streaming is queued, and a reply that still arrives between packets
   is taken.

ShimmerDriver 219/219 and ShimmerDriverPC 154/154 pass; the Java 8 MATLAB jar
builds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ehind a bare ACK's CRC

From the review of #349:

- The idle tests' radios now take each burst whole and let reads wait for
  their bytes, as a serial port does (WaitingTestRadio), so the IOThread can
  no longer race the test's writes. API_00043's idle tests use it too.
- The status-push, frame-after-ACK and status-reply tests now run with no
  link CRC, a 1-byte and a 2-byte one.
- The misframing test checks that the good packets after the damaged one
  still arrive; the status-reply test that the command is retired, the lock
  released, the timer cancelled and the packets either side parsed.

The CRC runs reproduced one more defect, which is fixed here: with a link CRC
on (the driver turns it on at connect where the firmware has it), the
records sent in the same burst as the opt-in's ACK were lost, 0 of 2. The
bare ACK's link CRC is left after the ACK is taken; the idle path read it as
an unknown byte and cleared the whole serial buffer, records included. With
the event channel on, the idle path now drops only the bytes it read.

All 7 tests in API_00044 fail on #348's code and pass here. ShimmerDriver
219/219, ShimmerDriverPC 155/155; the Java 8 MATLAB jar builds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DEV-971: fix five event-channel parser defects found in #348's review
… tests

From the review of #343:

- A Bluetooth configuration write before any read sent a Shimmer3R's
  byte 233 (DEV-99 audio mode and gain, DEV-1413 sound level) as 0, which
  turned the unit's audio mode off. It is now left out as byte 232 is,
  unless it was read or the sound level is turned on, on the same
  firmware. writeMem() takes a list of bytes to leave out. 3 of the 5
  tests in API_00047_AudioConfigWriteTest fail without it.
- The event channel probe's NACK now goes through processNackFromCommand(),
  which marks the event channel unsupported and does not report the NACK
  as a refused command. processEventChannelProbeNack() is gone.
- API_00036_ButtonLogModeTest and API_00037_ButtonLogModeConfigWriteTest
  are now API_00045 and API_00046: master's log-start-refused tests have
  those numbers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DEV-971: #343 review fixes - leave byte 233 out before a read, one NACK handler, renumber tests
DEV-971: keep configuration byte 232 on a full write, expose its fields, probe for the event channel
Conflicts, all resolved by keeping both sides:
- ShimmerBluetooth: the command and response maps (GET_AUDIO_STATUS and
  GET_EVENT_CHANNEL_STATUS), and the in-stream response branches.
- ShimmerObject: the 0xB9-0xBB and 0xBC-0xBD command constants.
- Configuration: the AUDIO_MODE and BUTTON_MODE/LOG_TRIGGERS/TTL_INPUT labels.
- ConfigByteLayoutShimmer3: byte 232's index beside the audio layout.
- SensorSoundLevel: the parse sets the audio mode and marks byte 233 read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Master's byte 233 rule (#351) leaves the byte out of a configuration
  written before it is read, unless it was read or the sound level is on.
  An audio mode set here before a read was therefore not written.
  SensorSoundLevel.isAudioConfigKnown() now takes the device and also
  counts an audio mode that differs from the one read, the same test
  configBytesGenerate() uses to write it. Off set before a read still
  leaves the Shimmer's own. API_00047 gains two tests; the first failed
  on the merged code.
- API_00042_Shimmer3rAudioStatusTest is now API_00048: master's
  API_00042_EventRecordFileTest has that number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…TATUS test

Harith's 2610c37 added its test to API_00042_Shimmer3rAudioStatusTest,
which this branch renamed to API_00048. Git carried the addition across the
rename, so nothing needed resolving by hand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JongChern
JongChern merged commit bc36f76 into DEV-1459 Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants